package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SysAnnounManagement;
import com.ruoyi.system.service.ISysAnnounManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * 大赛公告管理 信息操作处理
 *
 * @author ganshiyu
 */
@Api("大赛公告管理")
@RestController
@RequestMapping("/system/AnnounManagement")
public class SysAnnounManagementController {
     @Autowired
     ISysAnnounManagementService iSysAnnounManagementService;


     /**
      * 大赛公告管理  条件查询+分页
      * 后台管理和校园管理平台共同使用
      * @param sysAnnounManagement 实体类
      * @return 对象列表
      */
     @ApiOperation("条件查询+分页")
     @ApiImplicitParam(name = "sysAnnounManagement", value = "大赛公告管理实体类", required = true,dataType = "sysAnnounManagement")
     @GetMapping("selectByPage")
     public Map<String, Object> selectByPage(SysAnnounManagement sysAnnounManagement) {
          Map<String, Object> map = iSysAnnounManagementService.selectByPage(sysAnnounManagement);
          return map;
     }

     /**
      * 大赛公告添加
      * 后台管理和校园管理平台共同使用
      * @param sysAnnounManagement 实体类
      * @return 结果
      */
     @ApiOperation("大赛公告添加")
     @ApiImplicitParam(name = "sysAnnounManagement", value = "大赛公告管理实体类", required = true,dataType = "sysAnnounManagement")
     @PostMapping("insert")
     public AjaxResult insertAnnounManagement(SysAnnounManagement sysAnnounManagement, MultipartFile amPicFile) {
          sysAnnounManagement.setAmPicFile(amPicFile);
          int i = iSysAnnounManagementService.insertAnnounManagement(sysAnnounManagement);
          return AjaxResult.success();
     }

     /**
      * 修改大赛公告管理状态
      * 后台管理和校园管理平台共同使用
      * @param amid 实体类
      * @return 结果
      */
     @ApiOperation("修改大赛公告管理状态")
     @ApiImplicitParam(name = "amid", value = "大赛公告id", required = true,dataType = "int")
     @PostMapping("editState")
     public AjaxResult editState(int amid) {
          int i = iSysAnnounManagementService.editState(amid);
       return AjaxResult.success();
     }

     /**
      *  通过id查询对象
      *  后台管理和校园管理平台共同使用
      * @param amid
      * @return 对象
      */
     @ApiOperation("通过id查询对象")
     @ApiImplicitParam(name = "amid", value = "大赛公告id", required = true,dataType = "int")
     @PostMapping("selectById")
     public SysAnnounManagement selectById(int amid) {
          SysAnnounManagement sysAnnounManagement = iSysAnnounManagementService.selectById(amid);
          return sysAnnounManagement;
     }
     /**
      * 修改大赛公告
      * 后台管理和校园管理平台共同使用
      * @param sysAnnounManagement 实体类
      * @return 结果
      */
     @ApiOperation("修改大赛公告")
     @ApiImplicitParam(name = "sysAnnounManagement", value = "大赛公告管理实体类", required = true,dataType = "sysAnnounManagement")
     @PostMapping("edit")
     public AjaxResult edit(SysAnnounManagement sysAnnounManagement,MultipartFile amPicFile) {
          System.out.println(sysAnnounManagement);
          sysAnnounManagement.setAmPicFile(amPicFile);
          int i = iSysAnnounManagementService.edit(sysAnnounManagement);
          return AjaxResult.success();
     }

     /**
      *  删除大赛公告
      *  后台管理和校园管理平台共同使用
      * @param amid
      * @return 结果
      */
     @ApiOperation("删除大赛公告")
     @ApiImplicitParam(name = "amid", value = "大赛公告id", required = true,dataType = "int")
     @PostMapping("remove")
     public AjaxResult remove(int amid) {
          int i = iSysAnnounManagementService.remove(amid);
          return AjaxResult.success();
     }

     /*
      * 查询大赛公告标题
      * */
     @ApiOperation("查询大赛公告标题")
     @GetMapping("selectAmTitle")
     public List<SysAnnounManagement> selectAmTitle() {
          List<SysAnnounManagement> sysAnnounManagements = iSysAnnounManagementService.selectAmTitle();
          return sysAnnounManagements;
     }

     /*
      * 查询大赛公告状态
      * */
     @ApiOperation("查询大赛公告状态")
     @GetMapping("selectAmState")
     public List<SysAnnounManagement> selectAmState() {
          List<SysAnnounManagement> sysAnnounManagements = iSysAnnounManagementService.selectAmState();
          return sysAnnounManagements;
     }

    /**
     *
     */
    @ApiOperation("查询赛事公告")
    @GetMapping("/readAnnounMans")
    public Map<String,Object> readAnnounMans(SysAnnounManagement sysAnnounManagement){
        return iSysAnnounManagementService.readAnnounMans(sysAnnounManagement);
    }
}
